/**
 * @File name: modules/list.h
 * @Synopsis:
 * @Author: xing.dai@aliyun.com
 * @Version: 0.0.1
 * @Date: 2018-08-27 16:07
 */

#ifndef __LIST_H__
#define __LIST_H__

#include "types.h"
#include "stddef.h"

#define list_attach(list, node) list_add(list, node)

typedef struct _node {
    struct _node *next;
    struct _node *prev;
} node_t;

typedef struct _list {
    uint32 size;
    node_t *head;
    node_t *tail;
} list_t;

int node_init(node_t *node);
int list_init(list_t *list);
int list_add(list_t *list, node_t *node);
int list_traversal(list_t *list, int (tra_func)(node_t *));

#endif

